/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.easoft.code.pos.data.pojos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Eliu
 */
@Entity
@Table(name = "pos_caja")
@NamedQueries({
    @NamedQuery(name = "PosCaja.findAll", query = "SELECT p FROM PosCaja p"),
    @NamedQuery(name = "PosCaja.findById", query = "SELECT p FROM PosCaja p WHERE p.id = :id"),
    @NamedQuery(name = "PosCaja.findByNombre", query = "SELECT p FROM PosCaja p WHERE p.nombre = :nombre")})
public class PosCaja implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "nombre")
    private String nombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "posCaja")
    private Collection<PosPeriodoOperacion> posPeriodoOperacionCollection;
    @JoinColumn(name = "pos_impresora", referencedColumnName = "nombre")
    @ManyToOne
    private PosImpresora posImpresora;
    @JoinColumn(name = "def_bodega", referencedColumnName = "id")
    @ManyToOne
    private Bodega defBodega;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "posCaja")
    private Collection<PosFactura> posFacturaCollection;

    public PosCaja() {
    }

    public PosCaja(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Collection<PosPeriodoOperacion> getPosPeriodoOperacionCollection() {
        return posPeriodoOperacionCollection;
    }

    public void setPosPeriodoOperacionCollection(Collection<PosPeriodoOperacion> posPeriodoOperacionCollection) {
        this.posPeriodoOperacionCollection = posPeriodoOperacionCollection;
    }

    public PosImpresora getPosImpresora() {
        return posImpresora;
    }

    public void setPosImpresora(PosImpresora posImpresora) {
        this.posImpresora = posImpresora;
    }

    public Bodega getDefBodega() {
        return defBodega;
    }

    public void setDefBodega(Bodega defBodega) {
        this.defBodega = defBodega;
    }

    public Collection<PosFactura> getPosFacturaCollection() {
        return posFacturaCollection;
    }

    public void setPosFacturaCollection(Collection<PosFactura> posFacturaCollection) {
        this.posFacturaCollection = posFacturaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PosCaja)) {
            return false;
        }
        PosCaja other = (PosCaja) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.easoft.code.pos.data.pojos.PosCaja[ id=" + id + " ]";
    }

}
